//
//  DetailOneViewController.m
//  UI_APP_Project_Bean
//
//  Created by dllo on 16/6/23.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "DetailOneViewController.h"
#import "ActivityModel.h"
#import "PicTableViewCell.h"
#import "LabelTableViewCell.h"
#import "GetHeightTools.h"
@interface DetailOneViewController ()<UITableViewDataSource, UITableViewDelegate>


@end

@implementation DetailOneViewController

- (void)dealloc
{
    [_OwnerName release];
    [_modelTwo release];
    [super dealloc];
}


- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self config];

//    [self creatView];
    [self creatTableView];
}


-(void)config{
    
    self.navigationItem.title = self.modelTwo.title;
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"btn_nav_share@2x.png"] style:UIBarButtonItemStylePlain target:self action:@selector(forwardTo:)];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"btn_nav_back@2x.png"] style:UIBarButtonItemStylePlain target:self action:@selector(goGoBack:)];
    
}

// navigationbar 右图标动作
-(void)forwardTo:(UIBarButtonItem *)bar{
    
    
}
//  左图标 动作
-(void)goGoBack:(UIBarButtonItem *)bar{
    
    [self.navigationController popViewControllerAnimated:YES];
    
}


-(void)creatTableView{
    UITableView *tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 64, CGRectGetWidth(self.view.bounds), CGRectGetHeight(self.view.bounds) - 64)];
    
    [self.view addSubview:tableView];
    [tableView release];
    
    tableView.delegate = self;
    tableView.dataSource = self;
    
    [tableView registerClass:[PicTableViewCell class] forCellReuseIdentifier:@"picCell"];
    [tableView registerClass:[LabelTableViewCell class] forCellReuseIdentifier:@"labelCell"];
    
    
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 2;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.row == 0) {
        
          PicTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"picCell"];
            cell.picModel = self.modelTwo;
            cell.nameModel = self.OwnerName;
            return cell;

    }
    
  LabelTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"labelCell"];
            cell.activityModel = self.modelTwo;
    return cell;
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0) {
        return 280;
    }
    return [GetHeightTools heightWith:self.modelTwo.content];
    
}















- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
